<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<title>用户权限管理系统</title>
		<!-- Tell the browser to be responsive to screen width -->
		<meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
		<!-- Bootstrap 3.3.7 -->
		<link rel="stylesheet" href="__PUBLIC__/bower_components/bootstrap/dist/css/bootstrap.min.css">
		<!-- Font Awesome -->
		<link rel="stylesheet" href="__PUBLIC__/bower_components/font-awesome/css/font-awesome.min.css">
		<!-- Ionicons -->
		<link rel="stylesheet" href="__PUBLIC__/bower_components/Ionicons/css/ionicons.min.css">
		<!-- DataTables -->
		<link rel="stylesheet" href="__PUBLIC__/bower_components/datatables.net-bs/css/dataTables.bootstrap.min.css">
		<!-- Theme style -->
		<link rel="stylesheet" href="__PUBLIC__/dist/css/AdminLTE.min.css">
		<!-- AdminLTE Skins. Choose a skin from the css/skins
       folder instead of downloading all of them to reduce the load. -->
		<link rel="stylesheet" href="__PUBLIC__/dist/css/skins/_all-skins.min.css">

		<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
		<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
		<!--[if lt IE 9]>
  <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
  <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
  <![endif]-->

		<!-- Google Font -->
		<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,600,700,300italic,400italic,600italic">
		<style type="text/css">
			.dataTable {
				/*表格内容居中*/
				text-align: center;
			}
			
			#example1 th {
				/*数据表格标题文字居中*/
				text-align: center;
				vertical-align: middle!important;
			}
			.che{
				background-color: #36A4FF !important;
			}
			.che2{
				background-color: #36A4FF !important;
			}
		</style>
	</head>

	<body class="hold-transition skin-blue sidebar-mini">
		<!-- Site wrapper -->
		<div class="wrapper">

			<header class="main-header">
				<!-- Logo -->
				<a href="#" class="logo">
					<!-- mini logo for sidebar mini 50x50 pixels -->
					<span class="logo-mini"><b>R</b>MS</span>
					<!-- logo for regular state and mobile devices -->
					<span class="logo-lg"><b>Role</b>System</span>
				</a>
				<!-- Header Navbar: style can be found in header.less -->
				<nav class="navbar navbar-static-top">
					<!-- Sidebar toggle button-->
					<a href="#" class="sidebar-toggle" data-toggle="push-menu" role="button">
						<span class="sr-only">Toggle navigation</span>
						<span class="icon-bar"></span>
						<span class="icon-bar"></span>
						<span class="icon-bar"></span>
					</a>

					<div class="navbar-custom-menu">
						<ul class="nav navbar-nav">
							<!-- Messages: style can be found in dropdown.less-->
							<li class="dropdown messages-menu">
								<a href="#" class="dropdown-toggle" data-toggle="dropdown">
									<i class="fa fa-envelope-o"></i>
									<span class="label label-success">4</span>
								</a>
								<ul class="dropdown-menu">
									<li class="header">You have 4 messages</li>
									<li>
										<!-- inner menu: contains the actual data -->
										<ul class="menu">
											<li>
												<!-- start message -->
												<a href="#">
													<div class="pull-left">
														<img src="__PUBLIC__/dist/img/user2-160x160.jpg" class="img-circle" alt="User Image">
													</div>
													<h4>
                        Support Team
                        <small><i class="fa fa-clock-o"></i> 5 mins</small>
                      </h4>
													<p>Why not buy a new awesome theme?</p>
												</a>
											</li>
											<!-- end message -->
										</ul>
									</li>
									<li class="footer">
										<a href="#">See All Messages</a>
									</li>
								</ul>
							</li>
							<!-- Notifications: style can be found in dropdown.less -->
							<li class="dropdown notifications-menu">
								<a href="#" class="dropdown-toggle" data-toggle="dropdown">
									<i class="fa fa-bell-o"></i>
									<span class="label label-warning">10</span>
								</a>
								<ul class="dropdown-menu">
									<li class="header">You have 10 notifications</li>
									<li>
										<!-- inner menu: contains the actual data -->
										<ul class="menu">
											<li>
												<a href="#">
													<i class="fa fa-users text-aqua"></i> 5 new members joined today
												</a>
											</li>
										</ul>
									</li>
									<li class="footer">
										<a href="#">View all</a>
									</li>
								</ul>
							</li>
							<!-- Tasks: style can be found in dropdown.less -->
							<li class="dropdown tasks-menu">
								<a href="#" class="dropdown-toggle" data-toggle="dropdown">
									<i class="fa fa-flag-o"></i>
									<span class="label label-danger">9</span>
								</a>
								<ul class="dropdown-menu">
									<li class="header">You have 9 tasks</li>
									<li>
										<!-- inner menu: contains the actual data -->
										<ul class="menu">
											<li>
												<!-- Task item -->
												<a href="#">
													<h3>
                        Design some buttons
                        <small class="pull-right">20%</small>
                      </h3>
													<div class="progress xs">
														<div class="progress-bar progress-bar-aqua" style="width: 20%" role="progressbar" aria-valuenow="20" aria-valuemin="0" aria-valuemax="100">
															<span class="sr-only">20% Complete</span>
														</div>
													</div>
												</a>
											</li>
											<!-- end task item -->
										</ul>
									</li>
									<li class="footer">
										<a href="#">View all tasks</a>
									</li>
								</ul>
							</li>
							<!-- User Account: style can be found in dropdown.less -->
							<li class="dropdown user user-menu">
								<a href="#" class="dropdown-toggle" data-toggle="dropdown">
									<img src="__PUBLIC__/dist/img/user2-160x160.jpg" class="user-image" alt="User Image">
									<span class="hidden-xs">{$user}</span>
								</a>
								<ul class="dropdown-menu">
									<!-- User image -->
									<li class="user-header">
										<img src="__PUBLIC__/dist/img/user2-160x160.jpg" class="img-circle" alt="User Image">

										<p>
											{$user} - Web Developer
											<small>Member since Nov. 2012</small>
										</p>
									</li>
									<!-- Menu Body -->
									<li class="user-body">
										<div class="row">
											<div class="col-xs-4 text-center">
												<a href="#">Followers</a>
											</div>
											<div class="col-xs-4 text-center">
												<a href="#">Sales</a>
											</div>
											<div class="col-xs-4 text-center">
												<a href="#">Friends</a>
											</div>
										</div>
										<!-- /.row -->
									</li>
									<!-- Menu Footer-->
									<li class="user-footer">
										<div class="pull-right">
											<form method="post">
												<input type="hidden" name="info" id="info" value="exit" />
												<button type="submit" class="btn btn-danger">退出登录</button>
											</form>
										</div>
									</li>
								</ul>
							</li>
							<!-- Control Sidebar Toggle Button -->
						</ul>
					</div>
				</nav>
			</header>

			<!-- =============================================== -->

			<!-- Left side column. contains the sidebar -->
			<aside class="main-sidebar">
				<!-- sidebar: style can be found in sidebar.less -->
				<section class="sidebar">
					<!-- Sidebar user panel -->
					<div class="user-panel">
						<div class="pull-left image">
							<img src="__PUBLIC__/dist/img/user2-160x160.jpg" class="img-circle" alt="User Image">
						</div>
						<div class="pull-left info">
							<p>{$user}</p>
							<a href="#"><i class="fa fa-circle text-success"></i> Online</a>
						</div>
					</div>
					<!-- search form -->
					<form action="#" method="get" class="sidebar-form">
						<div class="input-group">
							<input type="text" name="q" class="form-control" placeholder="Search...">
							<span class="input-group-btn">
                <button type="submit" name="search" id="search-btn" class="btn btn-flat"><i class="fa fa-search"></i>
                </button>
              </span>
						</div>
					</form>
					<!-- /.search form -->
					<!-- sidebar menu: : style can be found in sidebar.less -->
					<ul class="sidebar-menu" data-widget="tree">
						<li class="header">主菜单</li>
					</ul>
				</section>
				<!-- /.sidebar -->
			</aside>

			<!-- =============================================== -->

			<!-- Content Wrapper. Contains page content -->
			<div class="content-wrapper">
				<!-- Content Header (Page header) -->
				<section class="content-header">
					<h1>角色管理</h1>
					<ol class="breadcrumb">
						<li>
							<a href="#"><i class="fa fa-dashboard"></i> Home</a>
						</li>
						<li>
							<a href="#">Examples</a>
						</li>
						<li class="active">Blank page</li>
					</ol>
				</section>

				<!-- Main content -->
				<section class="content">
					<div class="row">

						<!-- /.col -->
						<div class="col-md-7">
							<div class="box box-primary">
								<!-- /.box-header -->

								<div class="box-body">
									<div id="role_table_wrapper" class="dataTables_wrapper form-inline dt-bootstrap no-footer">
										<div class="row">
											<div class="col-sm-12">
												<div class="dataTables_filter" id="searchDiv">
													<!--<input placeholder="请输入名称" name="name" class="form-control" type="search" likeoption="true">
													<div class="btn-group">
														<button type="button" class="btn btn-primary" data-btn-type="search">查询</button>
													</div>-->
													<div id="editbtn" class="btn-group">
														<button type="button" id="add" class="btn btn-primary" data-btn-type="add" data-toggle="modal" data-target="#modal-default1">新增</button>
														<button type="button" id="edit" class="btn btn-warning" data-btn-type="edit" data-toggle="modal" data-target="#modal-default2">编辑</button>
														<button type="button" id="del" class="btn btn-danger" data-btn-type="delete" data-toggle="modal" data-target="#modal-default3">删除</button>
													</div>
												</div>
											</div>
										</div>
										<div class="row">
											<div class="col-sm-12">
												<table id="role_table" class="table table-bordered table-striped table-hover dataTable no-footer" style="width: 100%;" role="grid">
													<thead>
														<tr role="row">
															<th class="text-center sorting_disabled" rowspan="1" colspan="1" aria-label="序号">序号</th>
															<th class="text-center sorting" tabindex="0" aria-controls="role_table" rowspan="1" colspan="1" aria-label="名称: activate to sort column ascending">名称</th>
															<th class="text-center sorting" tabindex="0" aria-controls="role_table" rowspan="1" colspan="1" aria-label="编码: activate to sort column ascending">编码</th>
															<th class="text-center sorting_disabled" rowspan="1" colspan="1" aria-label="备注">备注</th>
														</tr>
													</thead>
													<tbody id="tbd">
													</tbody>
												</table>
												<div id="role_table_processing" class="dataTables_processing" style="display: none;">处理中...</div>
											</div>
										</div>
										<div class="row">
											<div class="col-sm-5"></div>
											<div class="col-sm-7"></div>
										</div>
									</div>
								</div>
								<!-- /.box-body -->
							</div>
						</div>
						<div class="col-md-5">
							<!-- Profile Image -->
							<div class="box box-primary">
								<!-- /.box-header -->

								<div class="box-body">
									<div id="userRole_table_wrapper" class="dataTables_wrapper form-inline dt-bootstrap no-footer">
										<div class="row">
											<div class="col-sm-12">
												<div class="dataTables_filter" id="searchDiv_userRole">
													<h5 id="roleName" class="pull-left"></h5>
													<input type="hidden" name="roleId" value="402880eb5c4ec2a4015c4ec591390000" id="roleId">
													<input placeholder="请输入用户名" name="user.name" class="form-control" type="search" likeoption="true">
													<div class="btn-group">
														<button type="button" class="btn btn-primary" data-btn-type="search">查询</button>
													</div>
													<div class="btn-group">
														<button type="button" class="btn btn-default" data-btn-type="selectUserRole">选择</button>
														<button id="deluser" type="button" class="btn btn-default" data-btn-type="deleteUserRole" data-toggle="modal" data-target="#modal-default4">删除</button>
													</div>
												</div>
											</div>
										</div>
										<div class="row">
											<div class="col-sm-12">
												<table id="userRole_table" class="table table-bordered table-striped table-hover dataTable no-footer" style="width: 100%;" role="grid" aria-describedby="userRole_table_info">
													<thead>
														<tr role="row">
															<th class="text-center sorting_disabled" rowspan="1" colspan="1" aria-label="序号">序号</th>
															<th class="text-center sorting" tabindex="0" aria-controls="userRole_table" rowspan="1" colspan="1" aria-label="用户名: activate to sort column ascending">用户名</th>
															<th class="text-center sorting" tabindex="0" aria-controls="userRole_table" rowspan="1" colspan="1" aria-label="登录名: activate to sort column ascending">登录名</th>
														</tr>
													</thead>
													<tbody id="userlist">
													</tbody>
												</table>
												<div id="userRole_table_processing" class="dataTables_processing" style="display: none;">处理中...</div>
											</div>
										</div>
									</div>
								</div>
								<!-- /.box-body -->
							</div>
							<!-- /.box -->
						</div>
					</div>
				</section>
				<!-- /.content -->
			</div>
			<!-- /.content-wrapper -->

			<footer class="main-footer">
				<div class="pull-right hidden-xs">
					<b>Version</b> 2.4.0
				</div>
				<strong>Copyright &copy; 2014-2016 <a href="https://adminlte.io">Almsaeed Studio</a>.</strong> All rights reserved.
			</footer>

			<!-- Add the sidebar's background. This div must be placed
       immediately after the control sidebar -->
			<div class="control-sidebar-bg"></div>
		</div>
		<!-- ./wrapper -->
		<div class="modal fade" id="modal-default3">
			<div class="modal-dialog">
				<div class="modal-content">
					<div class="modal-header">
						<button type="button" class="close" data-dismiss="modal" aria-label="Close">
                  <span aria-hidden="true">×</span></button>
						<h4 class="modal-title">删除角色</h4>
						<div class="pull-right col-sm-10 callout callout-success hide">
								<h4>删除成功！</h4>
								<p>成功删除角色！</p>
							</div>
							<div class="pull-right col-sm-10 callout callout-warning hide">
								<h4>删除失败！</h4>
								<p>该角色已绑定用户请先解绑用户后再进行操作！</p>
							</div>
					</div>
					<div class="modal-body">
						<form id="delForm" class="form-horizontal">
							<div class="box-body">
								确认删除<span style="color: red;" id="delmessage"></span>这一角色吗？
							</div>
							<!-- /.box-body -->
							<div class="box-footer">
								<button id="delbtn" type="button" class="btn btn-danger pull-right">删除</button>

							</div>
							<!-- /.box-footer -->
						</form>

					</div>
				</div>
				<!-- /.modal-content -->
			</div>
			<!-- /.modal-dialog -->
		</div>
		<div class="modal fade" id="modal-default1">
			<div class="modal-dialog">
				<div class="modal-content">
					<div class="modal-header">
						<button type="button" class="close" data-dismiss="modal" aria-label="Close">
                  <span aria-hidden="true">×</span></button>
						<h4 class="modal-title">添加新角色</h4>
						<div id="addsuccess" class="pull-right col-sm-10 callout callout-success hide">
								<h4>添加成功！</h4>
								<p>成功添加新角色！</p>
							</div>
							<div id="addwarning" class="pull-right col-sm-10 callout callout-warning hide">
								<h4>添加失败！</h4>
								<p>角色名已存在！</p>
							</div>
					</div>
					<div class="modal-body">
						<form id="addForm" class="form-horizontal">
							<div class="box-body">
								<div class="form-group">
									<label for="username" class="col-sm-2 control-label">名称</label>

									<div class="col-sm-10">
										<div class="input-group">
											<div class="input-group-addon">
												<i class="fa fa-user"></i>
											</div>
											<input type="text" class="form-control" name="title" id="addtitle" value="" placeholder="请输入名称">
										</div>
									</div>
								</div>
								<div class="form-group">
									<label for="nickname" class="col-sm-2 control-label">备注</label>
									<div class="col-sm-10">
										<div class="input-group">
											<div class="input-group-addon">
												<i class="fa fa-smile-o"></i>
											</div>
											<input type="text" value="" class="form-control" name="beizhu" id="addbeizhu" placeholder="请输入备注">
										</div>
									</div>
								</div>
							</div>
							<!-- /.box-body -->
							<div class="box-footer">
								<button id="addbtn" type="button" class="btn btn-info pull-right">保存</button>

							</div>
							<!-- /.box-footer -->
						</form>

					</div>
				</div>
				<!-- /.modal-content -->
			</div>
			<!-- /.modal-dialog -->
		</div>
		<div class="modal fade" id="modal-default2">
			<div class="modal-dialog">
				<div class="modal-content">
					<div class="modal-header">
						<button type="button" class="close" data-dismiss="modal" aria-label="Close">
                  <span aria-hidden="true">×</span></button>
						<h4 class="modal-title">更改角色信息</h4>
						<div id="editsuccess" class="pull-right col-sm-10 callout callout-success hide">
								<h4>更改成功！</h4>
								<p>成功更改角色信息！</p>
							</div>
							<div id="editwarning" class="pull-right col-sm-10 callout callout-warning hide">
								<h4>更改失败！</h4>
								<p>请编辑后再保存！</p>
							</div>
					</div>
					<div class="modal-body">
						<form id="editForm" class="form-horizontal">
							<div class="box-body">
								<div class="form-group">
									<label for="username" class="col-sm-2 control-label">名称</label>

									<div class="col-sm-10">
										<div class="input-group">
											<div class="input-group-addon">
												<i class="fa fa-user"></i>
											</div>
											<input type="text" class="form-control" name="title" id="title" value="">
										</div>
									</div>
								</div>
								<div class="form-group">
									<label for="nickname" class="col-sm-2 control-label">备注</label>
									<div class="col-sm-10">
										<div class="input-group">
											<div class="input-group-addon">
												<i class="fa fa-smile-o"></i>
											</div>
											<input type="text" value="" class="form-control" name="beizhu" id="beizhu">
										</div>
									</div>
								</div>
							</div>
							<!-- /.box-body -->
							<div class="box-footer">
								<button id="btnedit" type="button" class="btn btn-info pull-right">保存</button>

							</div>
							<!-- /.box-footer -->
						</form>

					</div>
				</div>
				<!-- /.modal-content -->
			</div>
			<!-- /.modal-dialog -->
		</div>
		<div class="modal fade" id="modal-default4">
			<div class="modal-dialog">
				<div class="modal-content">
					<div class="modal-header">
						<button type="button" class="close" data-dismiss="modal" aria-label="Close">
                  <span aria-hidden="true">×</span></button>
						<h4 class="modal-title">删除角色</h4>
						<div id="deluserY" class="pull-right col-sm-10 callout callout-success hide">
								<h4>删除成功！</h4>
								<p>成功删除用户！</p>
							</div>
							<div id="deluserN" class="pull-right col-sm-10 callout callout-warning hide">
								<h4>删除失败！</h4>
								<p>{$messaage}</p>
							</div>
					</div>
					<div class="modal-body">
						<form id="deluserForm" class="form-horizontal">
							<div class="box-body">
								确认删除<span style="color: red;" id="delusermessage"></span>这一用户吗？
							</div>
							<!-- /.box-body -->
							<div class="box-footer">
								<button id="deluserbtn" type="button" class="btn btn-danger pull-right">删除</button>

							</div>
							<!-- /.box-footer -->
						</form>

					</div>
				</div>
				<!-- /.modal-content -->
			</div>
			<!-- /.modal-dialog -->
		</div>
		

		<!-- jQuery 3 -->
		<script src="__PUBLIC__/bower_components/jquery/dist/jquery.min.js"></script>
		<!-- Bootstrap 3.3.7 -->
		<script src="__PUBLIC__/bower_components/bootstrap/dist/js/bootstrap.min.js"></script>
		<!-- DataTables -->
		<script src="__PUBLIC__/bower_components/datatables.net/js/jquery.dataTables.min.js"></script>
		<script src="__PUBLIC__/bower_components/datatables.net-bs/js/dataTables.bootstrap.min.js"></script>
		<!-- SlimScroll -->
		<script src="__PUBLIC__/bower_components/jquery-slimscroll/jquery.slimscroll.min.js"></script>
		<!-- FastClick -->
		<script src="__PUBLIC__/bower_components/fastclick/lib/fastclick.js"></script>
		<!-- AdminLTE App -->
		<script src="__PUBLIC__/dist/js/adminlte.min.js"></script>
		<!-- AdminLTE for demo purposes -->
		<script src="__PUBLIC__/dist/js/demo.js"></script>
		<script src="__PUBLIC__/js/loadMenu.js"></script>
		<script>
			$(document).ready(function() {
				$('.sidebar-menu').tree();
				$('.treeview:nth-child(3)').addClass('active');
				$('.treeview:nth-child(3)').addClass('menu-open');
				$('.treeview:nth-child(3) .treeview-menu').css('display', 'block');
				$('.treeview:nth-child(3) .treeview-menu li:nth-child(2)').addClass('active');
				$('#role_table').DataTable({
					"order": [
						[1, 'asc']
					],
//					开启服务器模式
					"processing": true,
					"serverSide": true,
					"language": {
						"sProcessing": "处理中...",
						"sLengthMenu": "显示 _MENU_ 项结果",
						"sZeroRecords": "没有匹配结果",
						"sInfo": "显示第 _START_ 至 _END_ 项结果，共 _TOTAL_ 项",
						"sInfoEmpty": "显示第 0 至 0 项结果，共 0 项",
						"sInfoFiltered": "(由 _MAX_ 项结果过滤)",
						"sInfoPostFix": "",
						"sSearch": "搜索:",
						"sUrl": "",
						"sEmptyTable": "表中数据为空",
						"sLoadingRecords": "载入中...",
						"sInfoThousands": ",",
						"oPaginate": {
							"sFirst": "首页",
							"sPrevious": "上页",
							"sNext": "下页",
							"sLast": "末页"
						},
						"oAria": {
							"sSortAscending": ": 以升序排列此列",
							"sSortDescending": ": 以降序排列此列"
						}
					},
					"ajax": '/home/user/authlist',
					"columns": [{
							"width": "25%"
						},
						{
							"width": "25%"
						},
						{
							"width": "25%"
						},
						{
							"width": "25%"
						},
					]
				})
				$('#userRole_table').DataTable({
					"order": [
						[1, 'asc']
					],
////					开启服务器模式
//					"processing": true,
//					"serverSide": true,
					"language": {
						"sProcessing": "处理中...",
						"sLengthMenu": "显示 _MENU_ 项结果",
						"sZeroRecords": "没有匹配结果",
						"sInfo": "显示第 _START_ 至 _END_ 项结果，共 _TOTAL_ 项",
						"sInfoEmpty": "显示第 0 至 0 项结果，共 0 项",
						"sInfoFiltered": "(由 _MAX_ 项结果过滤)",
						"sInfoPostFix": "",
						"sSearch": "搜索:",
						"sUrl": "",
						"sEmptyTable": "表中数据为空",
						"sLoadingRecords": "载入中...",
						"sInfoThousands": ",",
						"oPaginate": {
							"sFirst": "首页",
							"sPrevious": "上页",
							"sNext": "下页",
							"sLast": "末页"
						},
						"oAria": {
							"sSortAscending": ": 以升序排列此列",
							"sSortDescending": ": 以降序排列此列"
						}
					},
//					"ajax": '/home/user/userlist',
				})
				$("#tbd").on("click","tr",function(){
					var sid=$(this).children().slice(2).html();
					$(this).addClass('che');
					$(this).nextAll().removeClass('che');
					$(this).prevAll().removeClass('che');
					$.ajax({
						type:"post",
						url:"/home/user/userlist",
						data:{
							id:sid
						},
						success:function(data){
							$("#userRole_table tbody").empty();
							for (var i = 0; i < data['data'].length; i++) {
								var arr=[];
								arr.push('<tr><td>'+data['data'][i][0]+'</td><td>'+data['data'][i][1]+'</td><td>'+data['data'][i][2]+'</td></tr>')
								$("#userRole_table tbody").append(arr.join(''))
							}
						}
					});
				})
				$("#edit").on("click",function(){
					var title=$(".che").children(2).slice(1).html();
					var beizhu=$(".che").children(2).slice(3).html();
					$("#title").val(title)
					$("#beizhu").val(beizhu)
				})
				$("#btnedit").on("click",function(){
					var tle=$("#title").val()
					var bz=$("#beizhu").val()
					var sid=$(".che").children(2).slice(2).html();
					$.ajax({
						type:"post",
						url:"/home/user/role",
						data:{
							edittitle:tle,
							editbeizhu:bz,
							editid:sid
						},
						success:function(data){
							if(data.code==0){
								$(".callout-success").removeClass("hide")
								$(".callout-warning").addClass("hide")
								location.href="/home/user/role"
							}else{
								$("#editsuccess").addClass("hide")
								$("#editwarning").removeClass("hide")
							}
						}
					});
				})
				$("#addbtn").on("click",function(){
					var title=$("#addtitle").val();
					var beizhu=$("#addbeizhu").val();
					$.ajax({
						type:"post",
						url:"/home/user/role",
						data:{
							addtitle:title,
							addbeizhu:beizhu
						},
						success:function(data){
							if(data.code==0){
								$("#addsuccess").removeClass("hide")
								$("#addwarning").addClass("hide")
								location.href="/home/user/role"
							}else{
								$("#addsuccess").addClass("hide")
								$("#addwarning").removeClass("hide")
							}
						}
					});
				})
				$("#del").on("click",function(){
					var title=$(".che").children(2).slice(1).html();
					if(title){
						$("#delForm").css('display','block')
						$("#delmessage").html(title)
					}else{
						$("#delForm").css('display','none')
					}
				})
				$("#delbtn").on("click",function(){
					var sid=$(".che").children(2).slice(2).html();
					var title=$("#delmessage").html()
					$.ajax({
						type:"post",
						url:"/home/user/role",
						data:{
							id:sid,
							deltitle:title
						},
						success:function(data){
						}
					});
				})
				$("#userlist").on("click","tr",function(){
					var sid=$(this).children().slice(2).html();
					$(this).addClass('che2');
					$(this).nextAll().removeClass('che2');
					$(this).prevAll().removeClass('che2');
				})
				$("#deluser").on("click",function(){
					var title=$(".che2").children(2).slice(1).html();
					if(title){
						$("#deluserForm").css('display','block')
						$("#delusermessage").html(title)
					}else{
						$("#deluserForm").css('display','none')
					}
				})
				$("#deluserbtn").on("click",function(){
					var user=$(".che2").children().slice(2).html();
					$.ajax({
						type:"post",
						url:"/home/user/role",
						data:{
							deluser:user
						},
						success:function(data){
							if(data.code==0){
								$("#deluserY").removeClass("hide")
								$("#deluserN").addClass("hide")
								location.href="/home/user/role"
							}else{
								$("#deluserY").addClass("hide")
								$("#deluserN").removeClass("hide")
								$("#deluserForm").css('display','none')
							}
						}
					});
				})
			})
		</script>
	</body>

</html>